package IOPackage2;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @Auther:SunPeng
 * @Date:2020/7/29-07-29
 * @Description:IOPackage2
 * @version:1.0
 */
public class IODemo2 {
    public static void main(String[] args) {
        try{
            FileReader in = new FileReader("D:\\JavaTest\\Student.txt");
            FileWriter out = new FileWriter("D:\\JavaTest\\Student1.txt");

            char[] buffer = new char[100];
            while (in.read(buffer)!=-1){
                out.write(buffer);
                System.out.println(buffer);
            }

            in.close();
            out.close();
            System.out.println("拷贝成功");

        }catch (IOException e){
            System.out.println("IO错误");
            System.exit(-1);
        }
    }
}
